﻿using UnityEngine;
using System.Collections;

public class shoot_enemy1 : MonoBehaviour 
{
	public GameObject bullet_enemy;

	public GameObject player;

	public float treshold;

	public bool canShoot = true;

	// Use this for initialization
	void Start ()
	{
	
	}
	
	// Update is called once per frame
	void Update () 
	{
		//
		Transform parentPosition = GetComponentInParent<Transform>();


		//se a posicao x do meu parente e do meu tiro forem  maior ou iguais ao player x
		if(parentPosition.position.x + transform.position.x >= player.transform.position.x)
		{	// canshoot se torna true 
			if(canShoot)
			{	//instancie com o meu obijeto
				Instantiate(bullet_enemy, transform.position, Quaternion.identity);
			}// vira falso 
			canShoot = false;
		}

	


	}
}
